package com.eati.cm.auth;

import java.util.Collection;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import com.eati.cm.model.Login;
import com.eati.cm.model.ThirdPartyAccount;
import com.eati.cm.utils.CastUtil;
import com.fasterxml.jackson.core.JsonProcessingException;

public class LoginOnlineToken extends AbstractAuthenticationToken {
	private static final long serialVersionUID = 2464413086178054910L;
	long usrId;
	String credentials;

	@Override
	public Object getCredentials() {
		// TODO Auto-generated method stub
		return usrId;
	}

	@Override
	public Object getPrincipal() {
		// TODO Auto-generated method stub
		return credentials;
	}

	public LoginOnlineToken(long usrId, String credentials) {
		super(null);
		this.usrId = usrId;
		this.credentials = credentials;
	}
	
	public LoginOnlineToken(long usrId, Login log){
		super(null);
		this.usrId = usrId;
		this.credentials = genCredentials(log);
	}
	
	public String genCredentials(Login log) {
		return CastUtil.toJsonNoExcp(log);
	}
	
}
